package com.course.designpatterns.strategy;

/**
 * @author ：Jack Hao
 * @date ：Created in 2021/6/20 21:50
 * @description：
 */
public class Sorter1
{

    public static void sort(MyComparable[] arr){
        for (int i = 0; i <arr.length ; i++)
        {
            int minPos = i;
            for (int j = 0; j <arr.length ; j++)
            {
                minPos = arr[j].compareTo(arr[minPos]) == -1 ? j : minPos;
            }
            swap(arr,i,minPos);
        }
    }

    static void swap(MyComparable[] arr, int i,int j){
        MyComparable temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }
}
